package main

import (
	"fmt"
	"os/exec"
	"bytes"
	"io"

)
func runCommand() {
cmd0 := exec.Command("echo","-n","my first comma111111111111111nd come from golang")

stdout0,err := cmd0.StdoutPipe()
if err != nil {
	fmt.Printf("Error: xxxx %s\n",err)
	return
}


if err := cmd0.Start(); err != nil {
	fmt.Printf("Error: the command no.0 can not be startup: %s\n",err)
	return
}


/*
output0 := make([]byte,30)
n,err := stdout0.Read(output0)
if err != nil {
	fmt.Printf("error %s\n",err)
	return
}

fmt.Printf("%s\n", output0[:n] )
*/

var outputBuf0 bytes.Buffer
for {
	tmpOutput := make([]byte,5)
	n,err := stdout0.Read(tmpOutput);
	if err != nil {
		if err == io.EOF {
			break
		} else {
			fmt.Printf("Error: could not read data from the pipe: %s\n",err)
			return
		}
	}
	if n > 0 {
		outputBuf0.Write(tmpOutput[:n])
	}
}

fmt.Printf("%s\n",outputBuf0.String())

}

func main() {
	runCommand()
}
